//
//  EmotionView.m
//  Weibo
//
//  Created by Anasue on 9/28/15.
//  Copyright © 2015 vvusu. All rights reserved.
//

#import "EmotionView.h"
#import "Emotion.h"

@implementation EmotionView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.adjustsImageWhenHighlighted = NO;
    }
    return self;
}

- (void)setEmotion:(Emotion *)emotion
{
    _emotion = emotion;
    if (emotion.code) {
        [UIView setAnimationsEnabled:NO];
        [self setTitle:emotion.emoji forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:30];
    }else {
        NSString *icon = [NSString stringWithFormat:@"%@/%@",emotion.directory,emotion.png];
        UIImage *image = [UIImage imageWithName:icon];
        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self setImage:image forState:UIControlStateNormal];
    }
}

@end
